<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>06.vue事件小案例</title>
</head>
<body>
<div id="app">
    <input type="button" value="-" @click="subtractCount"/>
    <span>{{count}}</span>
    <input type="button" value="+" @click="addCount"/>

</div>
<script src="js/vue.js"></script>
<script>
    const app = new Vue({
        el:"#app",
        data:{
            count:1
        },
        methods:{
            addCount(){
                if(this.count < 10){
                    this.count++;
                }else{
                    alert("最多加10件")
                }
            },
            subtractCount(){
                if(this.count > 1){
                    this.count--;
                }else{
                    alert("不能少于1件")
                }
            }
        }
    })
</script>
</body>
</html>